package com.pay.manager.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.pay.manager.dao.GoodsOrderMapper;
import com.pay.manager.dao.OrderMapper;
import com.pay.manager.dto.GoodsOrderDTO;
import com.pay.manager.dto.OrderDTO;
import com.pay.manager.pojo.GoodsOrder;
import com.pay.manager.pojo.Merchant;
import com.pay.manager.pojo.PayOrder;
import com.pay.manager.response.PageDataResult;
import com.pay.manager.service.GoodsOrderService;
import com.pay.manager.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Title: OrderServiceImpl
 * @Description:
 * @author: yjw
 * @version: 1.0
 * @date: 2020/6/12 11:04
 */
@Service
public class GoodsOrderServiceImpl implements GoodsOrderService {
	
	@Autowired
	private GoodsOrderMapper gOrderDao;

	@Override
	public PageDataResult getGoodsOrderList(GoodsOrderDTO gOrderSearch, Integer pageNum, Integer pageSize) {
		 PageDataResult pageDataResult = new PageDataResult();
	        List<GoodsOrder> gOrder = gOrderDao.getGoodsOrderList(gOrderSearch);
	        PageHelper.startPage(pageNum, pageSize);
	        if(gOrder.size() != 0){
	            PageInfo<GoodsOrder> pageInfo = new PageInfo<>(gOrder);
	            pageDataResult.setList(gOrder);
	            pageDataResult.setTotals((int) pageInfo.getTotal());
	        }
	        return pageDataResult;
	}

	@Override
	public Map<String, Object> deletegOrder(Integer gid, String operationPwd) {
		Map<String,Object> data = new HashMap();
		if(operationPwd.equals("123456")) {
			gOrderDao.deleteById(gid);
			data.put("code",1);
			data.put("msg","商品订单信息已被删除！");
		}else {
			data.put("code",0);
			data.put("msg","操作密码有误！");
			return data;
		}
		return data;
	}


}
